package ch.ethz.fcl.metrobuzz.controller.gui.swing;

import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import net.miginfocom.swing.MigLayout;
import ch.ethz.fcl.metrobuzz.render.MBRenderer;

public class LodPanel extends JPanel {
	private static final long serialVersionUID = 1L;

	JSlider zone_level;
	JSlider render_level;
	JSlider group_level;

	public LodPanel(MBRenderer render) {
		this.setBackground(Color.LIGHT_GRAY);
		this.setLayout(new MigLayout());
		this.setBorder(BorderFactory.createTitledBorder("Level of Detail"));

		zone_level = new JSlider(JSlider.HORIZONTAL, 0, 2, 0);
		zone_level.createStandardLabels(1);
		zone_level.setMajorTickSpacing(1);
		zone_level.setMinorTickSpacing(1);
		zone_level.setPaintTicks(true);
		zone_level.setPaintLabels(true);
		zone_level.addChangeListener(new LODListener());

		render_level = new JSlider(JSlider.HORIZONTAL, 0, 100, 0);
		render_level.createStandardLabels(1);
		render_level.setMajorTickSpacing(20);
		render_level.setMinorTickSpacing(5);
		render_level.setPaintTicks(true);
		render_level.setPaintLabels(true);
		render_level.addChangeListener(new LODListener());

		group_level = new JSlider(JSlider.HORIZONTAL, 0, 40, 2);
		group_level.createStandardLabels(2);
		group_level.setMajorTickSpacing(10);
		group_level.setMinorTickSpacing(2);
		group_level.setPaintTicks(true);
		group_level.setPaintLabels(true);
		group_level.addChangeListener(new LODListener());

		this.add(new JLabel("Zone Level"));
		this.add(zone_level, "span, grow");
		this.add(new JLabel("Render Level"));
		this.add(render_level, "span, grow");
		this.add(new JLabel("Group Level"));
		this.add(group_level, "span, grow");
	}

	class LODListener implements ChangeListener {
		@Override
		public void stateChanged(ChangeEvent changeEvent) {
			Object source = changeEvent.getSource();
			if (source instanceof JSlider) {
				JSlider slider = (JSlider) source;
				if (!slider.getValueIsAdjusting()) {

				}
			}
		}
	}
}
